#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
ll n, A, B;
int a[1000000];
bool vis[1000000];
ll min_now[100102] = {INT_MAX};
ll ans = INT_MAX;
void dfs(ll now, ll sum)
{
    if (now < 1 || now > n)
        return;
    if (sum >= min_now[now])
        return;
    if (sum >= ans)
        return;
    if (B == now)
    {
        ans = min(ans, sum);
        return;
    }

    min_now[now] = sum;
    dfs(now + a[now], sum + 1);
    dfs(now - a[now], sum + 1);
}
void bfs()
{
    if (A == B)
    {
        cout << 0 << endl;
        return;
    }
    queue<int> q;
    q.push(A);
    vis[A] = 1;
    ll t = 0;
    while (++t)
    {
        ll x = q.size();
        if (x == 0)
        {
            cout << -1 << endl;
            return;
        }
        for (ll i = 0; i < x; i++)
        {
            ll p = q.front();
            q.pop();
            if (p - a[p] > 0)
            {
                if (!vis[p - a[p]])
                {
                    if (p - a[p] == B)
                    {
                        cout << t;
                        return;
                    }
                    q.push(p - a[p]);
                    vis[p - a[p]] = 1;
                }
            }
            if (p + a[p] <= n)
            {
                if (!vis[p + a[p]])
                {
                    if (p + a[p] == B)
                    {
                        cout << t;
                        return;
                    }
                    q.push(p + a[p]);
                    vis[p + a[p]] = 1;
                }
            }
        }
    }
}
void solve()
{
    cin >> n >> A >> B;
    for (ll i = 1; i <= n; i++)
    {
        min_now[i] = 1e18;
        cin >> a[i];
    }
    ans = INT_MAX;
    dfs(A, 0);
    cout << (ans == INT_MAX ? -1 : ans) << endl;
    // bfs();
    return;
}
int main()
{
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
